import redis
import json
from django.http import HttpResponse
from django.shortcuts import render


def remoteCar(request):
    action = request.GET.get("action", "")
    if action == "":
        return render(request, 'index.html')
    else:
        redis_client = redis.Redis("127.0.0.1", 6379, socket_timeout=0.1, socket_connect_timeout=0.1)
        redis_client.psetex("action", 100, action) # 100ms
        return HttpResponse(json.dumps({"code": 0}), content_type="application/json")